<script setup lang="ts">
/**
 * @description 表格列组件
 * @author
 * @version 1.0
 * @待完善功能 1.筛选 2.合并单元格
 */
import type { PropType } from 'vue'
import type { ITableCol } from '@/types'
import colDefault from './colDefault.vue'
import colEdit from './colEdit.vue'

defineProps({
  colItem: {
    type: Object as PropType<ITableCol>,
    default: () => ({}),
  },
  colIndex: {
    type: Number,
  },
})
</script>

<template>
  <vxe-column
    :key="colIndex + colItem.prop" :type="colItem.prop === 'isChecked' ? 'checkbox' : null"
    :tree-node="!!colItem.treeNode" :sortable="!!colItem.sortable" :field="colItem.prop" :visible="colItem.visible"
    :title="colItem.prop === 'isChecked' ? '' : colItem.label" :min-width="colItem.width" :fixed="colItem.fix"
    :edit-render="{}" :align="colItem.prop === 'isChecked' ? 'center' : colItem.align || 'left'"
  >
    <template #default="{ row }">
      <col-default :row="row" :col-item="colItem" />
    </template>
    <template #edit="{ row }">
      <col-edit :row="row" :col-item="colItem" />
    </template>
  </vxe-column>
</template>

<style scoped lang="scss"></style>
